package com.raibaz.atm.gui;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.raibaz.atm.R;
import com.raibaz.atm.businesslogic.Instruction;
import com.raibaz.atm.businesslogic.InstructionsUtils;

public class InstructionsAdapter extends ArrayAdapter<Instruction> {

	public InstructionsAdapter(Context cntx, int layoutId, ArrayList<Instruction> instructions) {
		super(cntx, layoutId, instructions);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View listView = inflater.inflate(R.layout.list_item, null);
		TextView tv = (TextView)listView.findViewById(R.id.listText);
		tv.setText(getItem(position).toString());
		if(tv.getText().equals(InstructionsUtils.ROUTE_START)) {
			ImageView iv = (ImageView)listView.findViewById(R.id.listImage);
			iv.setImageResource(R.drawable.start);
		}
		return listView;
	}
	
	

}
